<!doctype html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>扫码登录</title>
	<style type="text/css">
        *{padding: 0px;margin: 0px;}
        body{width: 1280px;height: 720px;
             background-image: url("__ROOT__/public/static/index/image/bodybg.png");background-repeat: no-repeat;font-family:'微软雅黑';
             overflow-x:hidden;overflow-y:hidden;}
	</style>

    <script src="__ROOT__/public/static/index/js/jquery-2.1.4.min.js" type="text/javascript"></script>
    <script src="__ROOT__/public/static/index/js/jquery.qrcode.min.js" type="text/javascript"></script>

</head>
<body>
        <img style="position:absolute;top:182px;left:1108px;width:112px;heigh:113px" src="__ROOT__/public/static/index/image/bp.png">
        <div id="code"  style="position:absolute;top:435px;left: 1108px;width:112px;heigh:113px;padding:5px 5px 2px 4px;text-align:center;background-color:#fff"></div>
        <div id="remind" style="position:absolute;top:550px;left: 1108px;width:112px;heigh:113px;padding:5px 5px 2px 4px;text-align:center;color:red;font-size:20px;display:none"></div>
</body>
<script type="text/javascript">
    $('html').css({
            cursor: 'none'
    });
    $("#code").qrcode({ 
        foreground: "blue",
        width: 107, //宽度 
        height:107, //高度 
        text: "{$login_code}|{$client_ip}" //任意内容 
    }); 
    
     function monitorDoScanCode(){
        $.ajax({  
            url: "{:Url('Index/monitorDoScanCode',['login_code'=>$login_code])}",  
            dataType: "json",  
            async:true, 
            cache: false,  
            // error: function (XMLHttpRequest, textStatus, errorThrown) {  
            //     $("#state").append("[state: " + textStatus + ", error: " + errorThrown + " ]<br/>");  
            //     if (textStatus == "timeout") { // 请求超时  
            //         longPolling(); // 递归调用  
            //     } else { // 其他错误，如网络错误等  
            //         longPolling();  
            //     }  
            // },  
            success: function (data) {
               $("#remind").show();
               if(data.state == 1){
                    // $("#p-info").text('登陆成功！正在进入...');
                    // $("#p-info").css('color',"green");
                    var battle_id = data.battle_id;
                    setTimeout(function(){
                        var url = "{:Url('Index/index')}"+"?battle_id="+battle_id;
                        window.location.href = url;
                    },'100')
                }else if(data.state == 0){
                    $("#remind").text('账户未激活！');
                    monitorDoScanCode();
                }else if(data.state == 2){
                    $("#remind").text("账户余额不足！");
                    monitorDoScanCode();
                }else if(data.state == 3){
                    $("#remind").text("账户已过期！");
                    monitorDoScanCode();
                }else if(data.state ==4){
                    $("#remind").text("账户被锁定！");
                    monitorDoScanCode();
                }
            }  
        });  
    }
    window.onload=function(){ 
        monitorDoScanCode();
    }

    setInterval("monitorDoScanCode()",30000);//1000为1秒钟
   
</script>
</html>